//
//  ViewController.m
//  滚动广告业
//
//  Created by YiXuePxh on 15/10/28.
//  Copyright © 2015年 上海益学. All rights reserved.
//

#import "ViewController.h"
#import "WHScrollAndPageView.h"
#define NUM 10
@interface ViewController ()<WHcrollViewViewDelegate>{
    WHScrollAndPageView* _whView;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    CGSize viewSize = [UIScreen mainScreen].bounds.size;
    _whView = [[WHScrollAndPageView alloc]initWithFrame:CGRectMake(0, 100, viewSize.width, 200)];
    //把N张图片放到imageView
    NSMutableArray* tempAry = [NSMutableArray array];
    for (int i = 0; i < NUM; i ++) {
        UIImageView* imageView = [[UIImageView alloc]init];
        imageView.contentMode = UIViewContentModeScaleAspectFit;
        [imageView setImage:[UIImage imageNamed:@"00001.jpg"]];
        [tempAry addObject:imageView];
    }
    //把imageView数组存在whView
    [_whView setImageViewAry:tempAry];
    //把图片展示view加载到当前页面
    [self.view addSubview:_whView];
    //开启自动翻页
    [_whView shouldAutoShow:YES];
    //遵守协议
    _whView.delegate = self;
}


#pragma mark 协议里面方法，点击某一页
-(void)didClickPage:(WHScrollAndPageView *)view atIndex:(NSInteger)index{
    NSLog(@"点击了第%li页",index);
}
#pragma mark 界面消失的时候，停止自动滚动
-(void)viewDidDisappear:(BOOL)animated
{
    [_whView shouldAutoShow:NO];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
